﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WSBackup
{
    public partial class FormProgress : Form
    {

        #region PROPERTIES

        public string MessageTime
        {
            set { lblTime.Text = value; }
        }

        public string MessageCounter
        {
            set { lblCounter.Text = value; }
        }

        public string MessageInfo
        {
            set { lblInfo.Text = value; }
        }

        public string MessageFile
        {
            set { lblFile.Text = value; }
        }

        //public int ProgressValue
        //{
        //    set { progressBar1.Value = value; }
        //}

        //public void Init(string Caption)
        //{
        //    lblCounter.Text = lblInfo.Text = lblFile.Text = string.Empty;
        //    this.Text = "Backup " + Caption;
        //}

        #endregion

        #region METHODS

        public FormProgress(string Caption)
        {
            InitializeComponent();
            lblCounter.Text = lblInfo.Text = lblFile.Text = string.Empty;
            this.Text = "Progress " + Caption;
        }

        #endregion

        #region EVENTS

        public event EventHandler<EventArgs> Canceled;

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            // Create a copy of the event to work with
            EventHandler<EventArgs> ea = Canceled;

            /* If there are no subscribers, eh will be null so we need to check to avoid a NullReferenceException. */
            if (ea != null)
                ea(this, e);
        }

        #endregion

        private string CompactString(string MyString, int Width, Font Font, TextFormatFlags FormatFlags)
        {

            string Result = MyString;
            TextRenderer.MeasureText(Result, Font, new System.Drawing.Size(Width, 0), FormatFlags | TextFormatFlags.ModifyString);
            return Result;
        }

    }
}
